import HTTP from '@/libs/http'

class PersonalApi extends HTTP {
  /**
   * @description: 个人资料
   * @author lsr
   * @date 2021.03.04
   */
  detail() {
    return this.request({
      method: 'GET',
      url: '/smart/smart-app/user/detail'
    })
  }
}
class PasswordApi extends HTTP {
  /**
   * @description: 忘记密码 - 手机号验证
   * @author lsr
   * @date 2021.09.02
   * @param {String} loginName 用户名
   * @param {String} validateCode 验证码
   */
  checkVerification({ loginName, validateCode }) {
    return this.request({
      method: 'POST',
      url: '/smart/smart-app/user/checkverification',
      data: {
        loginName,
        validateCode
      }
    })
  }

  /**
   * @description: 忘记密码 - 修改密码
   * @author lsr
   * @date 2021.03.04
   * @param {String} loginName 用户名
   * @param {String} newPassWord 新密码
   * @param {String} validateCode 验证码
   */
  updatePasswordBefore({ loginName, newPassWord }) {
    return this.request({
      method: 'POST',
      url: '/smart/smart-app/user/password_before',
      data: {
        loginName,
        newPassWord
      }
    })
  }

  /**
   * @description: 修改密码
   * @author lsr
   * @date 2021.03.05
   * @param {String} loginName 用户名
   * @param {String} oldPassWord 旧密码
   * @param {String} newPassWord 新密码
   */
  updatePasswordAfter({ loginName, oldPassWord, newPassWord }) {
    return this.request({
      method: 'POST',
      url: '/smart/smart-app/user/password_after',
      data: {
        loginName,
        oldPassWord,
        newPassWord
      }
    })
  }
}
class OpinionApi extends HTTP {
  /**
   * @description: APP意见反馈
   * @author lsr
   * @date 2021.03.05
   * @param {String} opinion 反馈内容
   */
  save({ opinion }) {
    return this.request({
      method: 'POST',
      url: '/smart/smart-app/user/save_opinion',
      data: {
        opinion
      }
    })
  }
}
class NotifyApi extends HTTP {
  /**
   * @description: 通知消息列表
   * @author lsr
   * @date 2021.07.15
   * @param {Int} recordSize 开始下标（第一条数据的下标为0）
   * @param {Int} pageSize 每页显示条数
   * @param {String} origin 消息来源
   */
  list({ recordSize, pageSize, origin }) {
    return this.request({
      method: 'GET',
      url: '/smart/smart-app/message/list',
      params: {
        recordSize,
        pageSize,
        origin
      }
    })
  }

  /**
   * @description: 通知消息列表
   * @author lsr
   * @date 2021.07.15
   * @param {String} code 消息编码
   */
  detail({ code }) {
    return this.request({
      method: 'GET',
      url: '/smart/smart-app/message/detail',
      params: {
        code
      }
    })
  }

  /**
   * @description: 是否有消息未读
   * @author lsr
   * @date 2021.07.15
   */
  count() {
    return this.request({
      method: 'GET',
      url: '/smart/smart-app/message/alert/count'
    })
  }
}

class MyClass {
  constructor() {
    this.Personal = new PersonalApi()
    this.Password = new PasswordApi()
    this.Opinion = new OpinionApi()
    this.Notify = new NotifyApi()
  }
}

const My = new MyClass()

export default My
